# Maintainer: Felix Yan <felixonmars@archlinux.org>

pkgname=golang-github-neelance-astrewrite
pkgver=0.0.20160511
_commit=99348263ae862cc230986ce88deaddbf7edcc034
pkgrel=1
pkgdesc="astrewrite module for Go"
arch=('any')
url="https://github.com/neelance/astrewrite"
license=('BSD')
depends=('go')
source=("$pkgname-$_commit.tar.gz::https://github.com/neelance/astrewrite/archive/$_commit.tar.gz")
sha512sums=('769665373a1a4168ab5672ddba56dfb0069c04c1868c384e92aed96e66b70708cd6ef1d3fffadc4e07b8c742b49f62f1ea0812c7fe405c9d857ef2af21cff099')

check() {
  export GO111MODULE=off
  export GOPATH="$srcdir/build:/usr/share/gocode"
  mkdir -p "$srcdir"/build/src/github.com/neelance
  cp -a "$srcdir"/astrewrite-$_commit "$srcdir"/build/src/github.com/neelance/astrewrite
  cd "$srcdir"/build/src/github.com/neelance/astrewrite
  go test -v $(go list ./...)
}

package() {
  mkdir -p "$pkgdir"/usr/share/gocode/src/github.com/neelance
  cp -a "$srcdir"/astrewrite-$_commit "$pkgdir"/usr/share/gocode/src/github.com/neelance/astrewrite

  install -Dm644 astrewrite-$_commit/LICENSE -t "$pkgdir"/usr/share/licenses/$pkgname/
}
